#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
#define MAX_SIZE (int)1e5+10
int arr[MAX_SIZE];
int dp[MAX_SIZE];
int main() 
{
	int n = 0;
	int q;
	cin >> n >> q;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		dp[i] = arr[i] + dp[i - 1];
	}
	while (q--)
	{
		int i, j;
		cin >> i >> j;
		cout << dp[j] - dp[i - 1];
	}
}
